package com.docker.apps.order.vo;

import android.databinding.ObservableArrayList;
import android.databinding.ObservableList;
import android.text.TextUtils;
import android.view.View;

import com.alibaba.android.arouter.launcher.ARouter;
import com.dcbfhd.utilcode.utils.ToastUtils;
import com.docker.apps.BR;
import com.docker.apps.R;
import com.docker.apps.afterservice.vm.AfterServiceViewModel;
import com.docker.common.common.model.BaseItemModel;
import com.docker.common.common.model.BaseSampleItem;
import com.docker.common.common.model.OnItemClickListener;
import com.docker.common.common.router.AppRouter;

import java.util.ArrayList;

import me.tatarka.bindingcollectionadapter2.ItemBinding;

public class AfterServiceVo extends BaseSampleItem {


    /**
     * id : 133z
     * memberid : 3
     * status : 4
     * circleid : 1
     * inputtime : 1583251200
     * logistic : 3416
     * logisticsNo : 110011100
     * receiveTel : 13056385770
     * payTime : 0
     * paytotal : 0.06
     * arrive_time : 还有五天到达
     * time_difference : 18326.3881
     * eva_status : 0
     * type :
     * refundsNo :
     * service_status : -1
     * return_id :
     * circleName : 华仪丽佳
     */

    /*
    *
    *   "orderid": "1023",
            "payTime": "2020-03-03 14:39:54",
            "orderNo": "TYGS20030314392956943",
            "order_goods_id": "1022",
            "goodsName": "小李飞酒 · 酱香10年",
            "goodsImg": "static/var/upload/image/2020/01/2020011710231737156_992x996.png",
            "goodsNum": "1",
            "goodsPrice": "0.01",
            "goodsPoint": "50.00",
            "goodsid": "28"
    * */



    public String id;
    public String memberid;
    public String status;
    public String circleid;
    public String inputtime;
    public String logistic;
    public String logisticsNo;
    public String receiveTel;
    public String type;
    public String refundsNo;
    public String service_status;
    public String return_id;
    public String circleName;

    @Override
    public int getItemLayout() {
        return R.layout.pro_order_after_service_item;
    }

    @Override
    public OnItemClickListener getOnItemClickListener() {
        return null;//(item, view) -> ARouter.getInstance().build(AppRouter.ORDER_DETAIL).withString("orderid", ((AfterServiceVo) item).id).navigation();
    }

    public ItemBinding<AfterServiceGood> getAfterServiceItemBinding(AfterServiceViewModel afterServiceViewModel) {
        ItemBinding<AfterServiceGood> itemImgBinding = ItemBinding.<AfterServiceGood>of(BR.item,
                R.layout.pro_after_service_item_goods).bindExtra(BR.viewmodel, afterServiceViewModel);
        return itemImgBinding;
    }

    ObservableList<AfterServiceGood> innerResource = new ObservableArrayList<>();

    public ObservableList<AfterServiceGood> getInnerResource() {
        if (innerResource.size() == 0) {
            innerResource.addAll(goods_info);
        }
        return innerResource;
    }


    public ArrayList<AfterServiceGood> goods_info;

    public ArrayList<AfterServiceGood> getGoods_info() {
        return goods_info;
    }

    public void setGoods_info(ArrayList<AfterServiceGood> goods_info) {
        this.goods_info = goods_info;
    }

    /*
    *  /*
    *
    *   "orderid": "1023",
            "payTime": "2020-03-03 14:39:54",
            "orderNo": "TYGS20030314392956943",
            "order_goods_id": "1022",
            "goodsName": "小李飞酒 · 酱香10年",
            "goodsImg": "static/var/upload/image/2020/01/2020011710231737156_992x996.png",
            "goodsNum": "1",
            "goodsPrice": "0.01",
            "goodsPoint": "50.00",
            "goodsid": "28"
    * */


    public static class AfterServiceGood extends BaseSampleItem {

        /*"returnId": "1",
            "returnTime": "2020-03-12 17:32:11",
            "refundsNo": "TYGS20200312053211",
        * */

        public String returnId;
        public String returnTime;
        public String refundsNo;

        /*
        * 申请中列表返回status
待审核|0        显示 取消申请 修改申请

同意申请|1      显示 填写物流单号
已完成|2
驳回申请|3
买家邮寄|4
商家换货邮寄|5
取消|10
        * */
        public int status = -1;


        public String goodsTotal;

        public String payTime;
        public String orderNo;
        public String order_goods_id;
        public String goodsName;
        public String goodsImg;
        public String goodsNum;
        public String goodsPrice;
        public String goodsPoint;
        public String goodsid;
        public String orderid;
        public String dynamicid;

        public String inputtime;

        public String type;
        public String total;
        public String returnNum;


        public String name;
        public String price;
        public String point;
        public String img;
        public String sku_id;
        public String sku_attr;

        //        public String refundsNo;
        public String isservice;//0全部 1 成功 3失败

        @Override
        public int getItemLayout() {
            return R.layout.pro_after_service_item_goods;
        }


        @Override
        public OnItemClickListener getOnItemClickListener() {


            return (item, view) -> {
                if (TextUtils.isEmpty(((AfterServiceGood) item).orderNo)) {
                    ARouter.getInstance().build(AppRouter.ORDER_AFTER_DETAIL)
                            .withSerializable("info", this).withString("refundsNo", refundsNo).navigation();
                } else {
//                    ARouter.getInstance().build(AppRouter.CIRCLE_dynamic_v2_detail).withString("dynamicId", ((AfterServiceGood) item).dynamicid).navigation();
                }
            };


//            if (TextUtils.isEmpty(refundsNo)) {
////                ToastUtils.showShort("没有售后单号");
//                return null;
//            } else{
//                return (item, view) -> ARouter.getInstance().build(AppRouter.ORDER_AFTER_DETAIL)
//                        .withSerializable("info", this).withString("refundsNo", refundsNo).navigation();
//            }

        }
    }
}
